import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { User } from './users.entity';
import { ERestartNotif } from '../../enums/restart.enum';

@Entity()
export class Note {
    constructor(props?: Partial<Note>) {
        Object.assign(this, props);
    }

    @PrimaryGeneratedColumn('uuid')
    public id!: string;

    @ManyToOne(() => User, (user) => user.telegramId)
    public user!: User;
    @Index()
    @Column({ nullable: true })
    public userTelegramId!: string;

    @ApiProperty({ example: 'buy eggs', description: 'description action' })
    @Column({
        nullable: true,
    })
    public message!: string;

    @ApiProperty({ example: '21.23.1990', description: 'date notification' })
    @Column({
        nullable: true,
        type: 'timestamptz',
    })
    public dateNotif!: Date;

    @Column({ enum: ERestartNotif })
    public restartMode!: ERestartNotif;

    @ApiProperty({ example: '21.23.1990', description: 'date registration' })
    @CreateDateColumn({ nullable: true, name: 'created_at', type: 'timestamptz' })
    createdAt!: Date;
}
